/////////
// Replictaion syntax for additional analyses of the paper 
// Vierus & Ziller (2025) - Political support in times of progressive policy change and radical-right populist party success
///////// 

//intalling ados
local adolist fre rev

foreach ado in `adolist' {
    cap which `ado'
    if _rc != 0 {
        di in red "`ado' is not installed. Installing now..."
        ssc install `ado'
    }
    else {
        di in green "`ado' is already installed."
		}
}
	
//Setup working directory & loading dataset
cd "WORKING DIRECTORY"
use "MPDataset_MPDS2021a_stata14.dta", clear 

//Creating country sample according to main analyses
drop if country != 21 &  country != 82  & country != 13 & country != 83 & country != 14 & country != 31 & country != 41 &  country != 51 &  country != 22 &  country !=  12 &  country != 11 

//Select time frame
drop if edate < td(01jan2010) | edate > td(01jan2020) 
tostring date, gen(date_s)
gen year_s = substr(date_s,1,4)
fre year_s
destring year_s, gen(year)

//Creating reacionary score 
//Consisting of anti-climate change, anti-equality and anti-immigrant positions
//Anti immigration
fre per601 
recode per601 per501  per503 (0 = .)

//Anti climate change
fre per501 
rev per501, replace

//Anti equality 
fre per503
rev per503, replace

//Creating mean index
alpha per601 per501 per503, item gen(reactionary)

//Comparison right-wing populist parties vs other parties (RWPs taken from PopuList 2)
sort partyname
gen populist = 0
	replace populist = 1 if party == 21917 //Flemish Interest
	replace populist = 1 if party == 72721 //Freedom and Direct Democracy
	replace populist = 1 if party == 82720 //Freedom and Direct Democarcy - Tomio Okamura
	replace populist = 1 if party == 82952 //Public Affairs
	replace populist = 1 if party == 41953 //deu: Alternative for Germany
	replace populist = 1 if party == 13720 //Danish People's Party
	replace populist = 1 if party == 13730 //The new right
	replace populist = 1 if party ==  83720 //Conservative People's Party of Estonia
	replace populist = 1 if party == 14820 //True Finns
	replace populist = 1 if party == 31720 //fra: National Front
	replace populist = 1 if party == 51951 //United Kingdom Independence Party GB
	replace populist = 1 if party == 22730 //Forum for Democracy
	replace populist = 1 if party == 22722 //Party of Freedom
	replace populist = 1 if party == 12951 //nor: Progress Party
	replace populist = 1 if party ==  11710 // "Sweden Democrats"

//Output
bys country: tabstat reactionary, by(populist) 
tabstat reactionary, by(populist)	
table country populist, stat(mean reactionary)  nformat(%5.2f) 








